<?php

class Site_hook {
 	
	private $ci;
	
 	public function __construct()
 	{
 		log_message('debug', 'Site hook library initialized.');
		
		$this->ci =& get_instance();
 	}
	
	public function display_projects()
	{	
		$aAreas = array(
			9 => 1, //car
			10 => 2, //bus
			11 => 3, //tube
			12 => 4, //train
			13 => 5, //motorcycle
			14 => 6 //bicycle
		);
		
		if(isset($aAreas[$this->ci->iPageId]))
		{
			$this->ci->aPageJs[] = array(
								'combine_js' => true,
								'base_href' => '/media/js',
								'js' => array('jquery_lightbox'),
								'version' => '1.0'
			);
			
			$this->ci->aPageCss[] = array(
								'combine_css' => true,
								'base_href' => '/media/css',
								'css' => array('jquery_lightbox'),
								'media' => 'all',
								'version' => '1.0'
			);
			
			$iArea = $aAreas[$this->ci->iPageId];
			
			$this->ci->load->model('db/views/baa_projects_extended', 'vw_baa_projects_extended');
			
			$this->ci->vw_baa_projects_extended->clear();
			$this->ci->vw_baa_projects_extended->project_area = $iArea;
			$this->ci->vw_baa_projects_extended->project_status = 'LI';
			
			$aOptions = array();
			$aOptions[] = array('order_by' => array('project_date_year', 'ASC'));
			$aOptions[] = array('order_by' => array('project_date_month', 'DESC'));
			
			$qProjects = $this->ci->vw_baa_projects_extended->get($aOptions);
			
			$this->aData['qProjects'] = $qProjects;
			
			$this->aData['sHeader'] = $this->ci->load->view('platform/'.$this->ci->sPlatform.'/hooks/projects_header_'.$iArea, $this->aData, true);
			
			$this->ci->load->view('platform/'.$this->ci->sPlatform.'/hooks/projects', $this->aData);
		}
	}
}

?>